<?php

class User extends CI_Model{
	
	function get_user_info(){
		
		$q = "select * from clients where BINARY email = '".$this->session->userdata('username')."'";
		
		$res = $this->db->query($q);
		if($res->num_rows() > 0){
			return $res->row();
		}
		else{
			return false;
		}
		
	}// end function get user info..
	function update(){
		
		if($this->input->post('password') != ''){
			$data = array(
				'password' => $this->input->post('password'),
				'fname' => $this->input->post('fname'),
				'lname' => $this->input->post('lname'),
				'address' => $this->input->post('address'),
				'office_phone' => $this->input->post('office_phone'),
				'mobile' => $this->input->post('mobile'),
			);
		} 
		else{
			$data = array(
				'fname' => $this->input->post('fname'),
				'lname' => $this->input->post('lname'),
				'address' => $this->input->post('address'),
				'office_phone' => $this->input->post('office_phone'),
				'mobile' => $this->input->post('mobile'),
			);
		}
		$this->db->where('email',$this->session->userdata('username'));
		$res = $this->db->update('clients',$data);
		
		return ($res) ? true:false;
		
	}// end function update..
	
}// end user..